package com.justnow;

public class Solution7 {
    public static boolean binaryFind(int nums[], int k) {
        int low = 0, high = nums.length - 1;
        int middle = (low + high) / 2;
        while (low < high) {
            if (nums[middle] < k) {
                low = middle + 1;
            } else if (nums[middle] > k) {
                high = middle - 1;
            } else {
                return true;
            }
            middle = (low + high) / 2;
        }
        return false;
    }

    public static void main(String[] args) {
        boolean b = Solution7.binaryFind(new int[]{1, 3, 5, 9, 10}, 9);
        System.out.println(b);
    }
}
